#include "addresultwindow.h"
#include "ui_addresultwindow.h"
#include <QMessageBox>
#include <QDebug>

AddResultWindow::AddResultWindow(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::AddResultWindow)
{
    ui->setupUi(this);
}

AddResultWindow::~AddResultWindow()
{
    delete ui;
}

void AddResultWindow::on_addButton_clicked()
{
    qDebug() << "Add button clicked";

    int collegeId = ui->collegeIdSpinBox->value();
    int eventId = ui->eventIdSpinBox->value();
    int rank = ui->rankSpinBox->value();

    if (collegeId > 0 && eventId > 0 && rank > 0) {
        emit resultAdded(collegeId, eventId, rank);
        QMessageBox::information(this, "提示", "比赛结果添加成功");
    } else {
        QMessageBox::warning(this, "警告", "所有字段都必须填写且大于0");
    }
}
